<template>
  <div class="head">
    <div class="tit">
      <button class="tex1">进港操作费汇总表</button>
    </div>
    <div class="line" />
    <el-row>
      <el-col :span="24">
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;flex-wrap: wrap;margin-top: 24px;justify-content: space-between;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 1286px;">
              <el-form-item class="text" label="签收上级网点" style="margin-left: 18px;" label-width="110px">
                <el-select v-model="form.aimSuperiorsNetworkNameId" class="input" placeholder="请选择" style="width: 286px;" @change="provinceChange">
                  <el-option v-for="item in List" :key="item.id" :label="item.networkName" :value="item.id" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="末端转运中心" label-width="110px">
                <el-select v-model="form.endTransferCentreId" class="input" placeholder="输入关键字后自动搜索" style="width: 286px;">
                  <el-option
                    v-for="item in TransferCenterList"
                    :key="item.id"
                    :label="item.transferCenter"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="上一站转运中心" label-width="110px">
                <el-select v-model="form.endBeforeTransferCentreId" class="input" placeholder="请选择" style="width: 286px;">
                  <el-option
                    v-for="item in TransferCenterList"
                    :key="item.id"
                    :label="item.transferCenter"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
                <el-button @click="khClear">重置</el-button>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;justify-content: space-between;flex-wrap: wrap;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 850px;">
              <el-form-item class="text" label="结算网点(总部付)" label-width="130px">
                <el-select v-model="form.settleNameId" placeholder="请选择" style="width: 286px;">
                  <el-option v-for="item in List" :key="item.id" :label="item.networkName" :value="item.id" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="结算网点(总部收)" label-width="130px">
                <el-select v-model="form.transferCentreId" placeholder="请选择" style="width: 286px;">
                  <el-option v-for="item in List" :key="item.id" :label="item.networkName" :value="item.id" />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button @click="onSubmit"><i class="el-icon-upload2" />导出</el-button>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;justify-content: space-between;flex-wrap: wrap;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 1168px;">
              <el-form-item class="text" label="日期">
                <el-date-picker
                  v-model="value"
                  type="daterange"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  style="width: 686px"
                  @change="changeTime"
                />
              </el-form-item>
              <!-- <el-form-item class="text" label="进出港">
                <el-select placeholder="请选择" style="width: 286px;">
                  <el-option v-for="item in cityList" :key="item.id" class="input" :label="item.city" :value="item.city" />
                </el-select>
              </el-form-item> -->
            </div>
          </el-form>
        </div>
        <el-table
          :data="tableData"
          border
          max-height="734"
          :header-cell-style="{ background: '#f6f6f6' }"
          style="width: 100%;margin-top: 19px;"
        >
          <el-table-column :index="table_index" type="index" width="50" align="center" />
          <el-table-column prop="collectDate" label="结算时间段" width="180" align="center" />
          <!-- <el-table-column prop="hqTransferCentre.transferCenter" width="140" label="末端转运中心名称" align="center" /> -->
          <el-table-column prop="endBeforeTransferCentre.transferCenter" width="150" label="上一站转运中心名称" align="center" />
          <el-table-column prop="aimSuperiorsNetworkName.networkName" width="140" label="签收上级网点名称" align="center" />
          <el-table-column prop="settleNameId" width="180" label="结算网点编码(总部应收)" align="center" />
          <el-table-column prop="settleName.networkName" width="180" label="结算网点名称(总部应收)" align="center" />
          <el-table-column prop="transferCentreId" width="180" label="结算网点编码(总部应付)" align="center" />
          <el-table-column prop="transferCentre.transferCenter" width="180" label="结算网点名称(总部应付)" align="center" />
          <el-table-column prop="autoSortNum" width="140" label="自动分拣票件量" align="center" />
          <el-table-column prop="autoSortSettleWeight" width="140" label="自动分拣结算重量" align="center" />
          <el-table-column prop="autoSortSettleAmount" width="140" label="自动分拣结算金额" align="center" />
          <el-table-column prop="unAutoSortNum" width="140" label="非自动分拣票件量" align="center" />
          <el-table-column prop="unAutoSortSettleWeight" width="150" label="非自动分拣结算重量" align="center" />
          <el-table-column prop="unAutoSortSettleAmount" width="150" label="非自动分拣结算金额" align="center" />
          <el-table-column prop="totalNum" width="130" label="合计票件量" align="center" />
          <el-table-column prop="settleWeight" width="130" label="合计结算重量" align="center" />
          <el-table-column prop="settleAmount" width="130" label="合计结算金额" align="center" />
          <el-table-column prop="hqTransferCentre.transferCenter" width="150" label="末端转运中心名称" align="center" />
          <el-table-column prop="endBeforeTransferCentre.transferCenter" width="150" label="上一级转运中心名称" align="center" />
          <el-table-column prop="aimSuperiorsNetworkName.networkName" width="150" label="签收上级网点名称" align="center" />
          <el-table-column prop="settleName.networkName" width="180" label="结算网点名称(总部应收)" align="center" />
          <el-table-column prop="transferCentre.transferCenter" width="180" label="结算网点名称(总部应付)" align="center" />

        </el-table>
        <div style="display: flex;justify-content: space-between;margin-top: 51px;">
          <div class="title2" />
          <div class="block" style="display: flex; justify-content: flex-end">
            <el-pagination
              background
              :current-page="current"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="10"
              layout="total, prev, pager, next"
              :total="+total"
              prev-text="上一页"
              next-text="下一页"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>

      </el-col>
    </el-row>
  </div>
</template>

<script>
import { TransferCenterApi, EnterOperateApi } from '@/api/HqFinancePanel'
import { getOutletsList } from '@/api/dashboard'

export default {

  components: {},
  data() {
    return {
      id: '1',
      ProvinceList: [], // 省
      cityList: [], // 市
      value: '',
      page: 1,
      pageSize: 10,
      form: {
        aimSuperiorsNetworkNameId: '',
        endBeforeTransferCentreId: '',
        endTime: '',
        endTransferCentreId: '',
        pageDate: {
          pageNum: 1,
          pageSize: 10
        },
        settleNameId: '',
        startTime: ''
        // transferCentreId: ''
      },
      tableData: [],
      current: '', // 页数
      pages: '', // 条数
      total: '', // 总数
      TransferCenterList: [], // 转运中心列表
      List: []// 网点列表
    }
  },

  computed: {},

  created() {
    this.TransferCenter()
    this.getOutlets()
  },

  methods: {
    // 序号
    table_index(index) {
      return (this.pages - 1) * this.current + index + 1
    },
    // 选择时间
    changeTime() {
      this.form.startTime = this.value[0]
      this.form.endTime = this.value[1]
    },
    // 上一页
    handleSizeChange(val) {
      this.form.pageDate.pageSize = val
      this.onSubmit()
    },
    // 下一页
    handleCurrentChange(val) {
      this.form.pageDate.pageNum = val
      this.onSubmit()
    },
    // 准运中心
    async TransferCenter() {
      const res = await TransferCenterApi()
      this.TransferCenterList = res.data
    },
    // 结算网点列表
    async getOutlets() {
      const res = await getOutletsList()
      this.List = res.data
    },
    // 重置
    khClear() {
      Object.keys(this.form).forEach((key) => {
        if (key !== 'pageDate') {
          this.form[key] = ''
        }
      })
      this.tableData = []
      this.value = ''
      this.total = ''
      this.current = ''
      this.pages = ''
    },
    // 查询
    async onSubmit() {
      const res = await EnterOperateApi(this.form)
      console.log(res)
      this.tableData = res.data.data
      this.pages = res.data.pages
      this.current = res.data.current
      this.total = res.data.total
    }
  }
}

</script>
<style  scoped lang="scss">
.tit {
  display: flex;
  .tex1 {
    margin-right: 48px;
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
    background: #fff;
    border: 1px #fff solid;
  }

  .active {
    font-family: Source Han Sans CN;
    font-weight: 700;
    color: #2087D0;
    position: relative;

  }

  .active::before {
    position: absolute;
    content: '';
    width: 110px;
    height: 2px;
    background: #2087D0;
    border-radius: 1px;
    bottom: -20px;
    left: 50%;
    transform: translate(-50%);
  }
}

.head {
  padding: 30px;
}

.title {
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
  margin-top: 20px;
}

.line {
  height: 1px;
  background: #D8D8D8;
  border-radius: 1px;
  margin-top: 19px;
}

.title1 {
   .text {
    font-size: 18px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;

    .input {
      width: 286px;
      height: 36px;
      background: #FFFFFF;
      border-radius: 4px;
    }

    .input1 {
      width: 708px;
      height: 36px;
      background: #FFFFFF;
      border: 1px solid #B4B4B4;
      border-radius: 4px;
    }
  }
}

.title2 {
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}
</style>
